package fr.umlv.m2.jee.portailEtudiant.service.Impl;

import fr.umlv.m2.jee.portailEtudiant.persistence.ITutorialDAO;
import fr.umlv.m2.jee.portailEtudiant.persistence.Tutorial;
import fr.umlv.m2.jee.portailEtudiant.service.DisplayTutorial;
import fr.umlv.m2.jee.portailEtudiant.service.IDisplayTutorialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: soufiane
 * Date: 19/03/11
 * Time: 20:09
 * To change this template use File | Settings | File Templates.
 */
@Service("defaultDisplayTutorialService")
public class DefaultDisplayTutorialService implements IDisplayTutorialService {

    @Autowired
    @Qualifier("hibernateTutorialDAO")
    private ITutorialDAO tutorialDao;

    @Override
    public List< DisplayTutorial > getAllDisplayTutorials() {
        List< DisplayTutorial > result = new ArrayList<DisplayTutorial>();

        for(Tutorial tutorial : tutorialDao.findAll()) {
            result.add(new DisplayTutorial(tutorial));
        }
        return result;
    }
}
